<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" lang="en">
	
	<h:head>
		<meta charset="utf-8">
		<title>T&amp;M Transporte de Cargas</title>
		<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
		<meta name="description" content="T&amp;M Transporte de Cargas"></meta>
		<meta name="author" content="José Gaspar Kuhnen Filho"></meta>
		<meta name="twitter:site" content="@gasparkf" /></meta>
		<meta http-equiv="X-UA-Compatible" content="IE=Edge"></meta>
		
		<!-- Le styles -->
		<link href="${facesContext.externalContext.requestContextPath}/assets/css/bootstrap.css" rel="stylesheet"></link>
		
		<link href="${facesContext.externalContext.requestContextPath}/assets/css/bootstrap-responsive.css" rel="stylesheet"></link>
		
		<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
		<h:outputText escape="false" value="&lt;!--[if lt IE 9]&gt;   &lt;script src=${facesContext.externalContext.requestContextPath}/assets/js/html5shiv.js&quot;&gt;&lt;/script&gt;  &lt;![endif]--&gt;"></h:outputText>
		
		
		<!-- Fav and touch icons -->
		<link rel="apple-touch-icon" href="${facesContext.externalContext.requestContextPath}/assets/ico/tm_logo_72.png"></link>
        <link rel="icon" href="${facesContext.externalContext.requestContextPath}/assets/ico/tm_logo_72.png"></link>
		<link rel="apple-touch-icon-precomposed" sizes="72x72" href="${facesContext.externalContext.requestContextPath}/assets/ico/tm_logo_72.png"></link>
		<link rel="shortcut icon" href="${facesContext.externalContext.requestContextPath}/assets/ico/tm_logo_72.png"></link>
	</h:head>
	
	<h:body style="background-image:url('../assets/img/grey_wash_wall.png')">
		
		<div class="container">
			<div class="row-fluid" style="padding-bottom: 50px; padding-top: 20px;">
				<div class="span3"></div>
				<div class="span6" align="center">
					<div id="tab" class="btn-group" data-toggle="buttons-radio">
				  		<a href="${facesContext.externalContext.requestContextPath}/blog/crud.jsf" class="btn btn-large" data-toggle="tab">Blog</a>
				  		<a href="${facesContext.externalContext.requestContextPath}/usuario/crud.jsf" class="btn btn-large" data-toggle="tab">Usuários</a>
				  	</div>
				</div>
				<div class="span3"></div>
			</div>
		<ui:param name="MB" value="#{UsuarioMB}"/>
		
		<h:panelGroup rendered="#{MB.modoListar}">
			<h:form>
				<div class="row-fluid">
					<div class="span3"></div>
					<div class="span6 well">
						<h:messages id="messages" globalOnly="true"
							style="border: 1px solid #999999;background-color:#ffffee;padding:6px;font-weight:bold"
							errorStyle="color:#ff0000;font-weight:bold" layout="table" />
						
						<p></p>
						
						<h:commandButton action="#{MB.criar}" value="Novo &raquo;" styleClass="btn btn-primary" />
						
						<p></p>
				
						<p:dataTable value="#{MB.lista}" var="obj">
				
							<p:column>
								<f:facet name="header">
									<h:outputText value="Nome" />
								</f:facet>
								<h:outputText value="#{obj.nome}" />
							</p:column>
				
							<p:column>
								<f:facet name="header">
									<h:outputText value="E-mail" />
								</f:facet>
								<h:outputText value="#{obj.email}" />
							</p:column>
				
							<p:column>
								<f:facet name="header">
									<h:outputText value="Editar" />
								</f:facet>
								<h:commandButton value="Editar" action="#{MB.editar(obj)}" styleClass="btn btn-warning"/>
							</p:column>
						</p:dataTable>
					</div>
					<div class="span3"></div>
				</div>
			</h:form>
		</h:panelGroup>
		
		<h:panelGroup rendered="#{MB.modoEditar}">
			<h:form>
				<div class="row-fluid">
					<div class="span2">
					</div>
					<div class="span8 well">
						<h:messages id="mensagens"></h:messages>
						<p></p>
						
						<label>Nome:</label>
						<h:inputText id="nome" value="#{MB.entidade.nome}" maxlength="20" styleClass="span5"/>
						
						<label>Senha:</label>
						<h:inputSecret id="senha" value="#{MB.entidade.senha}" maxlength="20" styleClass="span5"/>
						
						<label>Email:</label>
						<h:inputText id="email" value="#{MB.entidade.email}" maxlength="100" styleClass="span5"/>
						<hr></hr>
						
						<h:commandButton 
							value="Gravar" 
							action="#{MB.gravar}"
							update="mensagens"
							styleClass="btn btn-primary"/>
						
						<h:commandButton 
							value="Excluir" 
							action="#{MB.excluir}"
							rendered="#{MB.exibirExcluir}"
							onclick="return confirm('Confirma exclusão do registro?')" 
							styleClass="btn btn-danger pull-right"/>
					</div>
						
					<div class="span2">
					</div>
				</div>		
			</h:form>
		</h:panelGroup>
		</div>
	</h:body>
</html>